
/*
 * Copyright (C) 2010 Young, Fey <fey.young@gmail.com>
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 * 
 */

package com.youngfey.chess

/**
 *
 * @author Young, Fey <fey.young@gmail.com>
 */
class Evaluation {

    /**
     * Position value, which is expressed in 1% pawn units from
     * the point of view of White.
     * @return position value, 298 means that White is about 
     * 3 pawns up
     */
    short getScore() {
        score
    }

    /**
     * Get search depth, in ply (half moves)
     * @return How many moves deep it searched.
     */
    short getDepth() {
        depth
    }

    /**
     * How long it searched, in sec
     * @return How many seconds it searched
     */
    int getTime() {
        time
    }

    /**
     * Total number of positions it searched
     * @return How many nodes (positions) it searched
     */
    long getNodes() {
        nodes
    }

    /**
     * The speed at which it is running
     * @return How many kilo-nodes per second it searched
     */
    short getSpeed() {
        if(time == 0) return 0
        nodes / time / 1000
    }

    /**
     * Mate in n moves information
     * @return How many plys to get a mate. 0 means already
     * be mated, null means there is no force mate found.
     */
    Short getMate() {
        mate
    }

    /**
     * Get the main line
     * @return main line
     */
    List<Move> getMainLine() {
        mainLine
    }

    /**
     * To make sure depth, time and nodes won't less than 0
     * @throws IllegalStateException when any of them was less
     * than 0
     */
    void validate() {
        if(depth < 0 || time < 0 || nodes < 0) {
            throw new IllegalStateException()
        }
    }

    // For debug only
    @Override
    String toString() {
        "${this.class.name}$properties"
    }

    private short score
    private short depth
    private int time
    private long nodes
    private Short mate

    private List<Move> mainLine
}

